<template>
  <div style="text-align: left;" v-if="show">
    <a-row>
      <a-col :span="6" class="item">
        <span>订单号: </span>{{ this.type == '其他入库单'? data.otherInDepositoryNo : data.otherOutDepositoryNo }}
      </a-col>
      <a-col :span="6" class="item">
        <span>{{ this.type == '其他入库单'? '入库日期': '出库日期' }}: </span>{{ this.type == '其他入库单' ? data.beLaidUpTime : data.outDepositoryTime }}
      </a-col>
      <a-col :span="6" class="item">
        <span>仓库: </span>{{ data.depositoryName }}
      </a-col>
    </a-row>
    <a-row>
      <a-col :span="6" class="item">
        <span>创建人: </span>{{ data.createBy }}
      </a-col>
      <a-col :span="6" class="item">
        <span>创建日期: </span>{{ data.createTime }}
      </a-col>
      <a-col :span="6" class="item">
        <span>备注: </span>{{ data.remark }}
      </a-col>
    </a-row>
    <a-table
      :columns="columns"
      :data-source="data.materials"
      bordered />
  </div>
</template>

<script>
import { getAction } from '@/api/manage'
export default {
  name: "InOrOutOrder",
  data() {
    return {
      data: '',
      title:'',
      type: '',
      show: false,
      url: {
        getInOrderById: '/ghSupplychainOtherInDepositoryOrder/getById',
        getOutOrderById: '/ghSupplychainOtherOutDepositoryOrder/getById',
      },
      columns: [
        {
          title: '名称',
          dataIndex: 'materialName',
          scopedSlots: { customRender: 'materialName' },
        },{
          title: '型号',
          dataIndex: 'modelNumber',
        },{
          title: '规格',
          dataIndex: 'specifications',
        },{
          title: '品牌',
          dataIndex: 'brand',
        },{
          title: '市场价格',
          dataIndex: 'marketPrice',
        },{
          title: '预算价',
          dataIndex: 'estimatedCost',
        },{
          title: '数量',
          dataIndex: 'materialNum',
        },{
          title: '单价',
          dataIndex: 'unitPrice',
        },{
          title: '小计金额',
          customRender:function (record) {
            return record.materialNum * record.unitPrice
          }
        },{
          title: '备注',
          dataIndex: 'remark',
        }
      ]
    }
  },
  methods: {
    initData(params, title) {
      this.type = title;
      let url = '';
      if(title == '其他入库单') {
        url = this.url.getInOrderById;
      } else if(title == '其他出库单') {
        url = this.url.getOutOrderById
      }

      getAction(url, params)
        .then(res => {
          if (res.success) {
            this.data = res.result;
          }
        });
    }
  }
}
</script>
<style>
.item {
  padding: 15px
}
</style>